package com.web.dao;

import com.web.entity.InstantInfoCollection;
import com.web.entity.UserCollection;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserCollectionMapper {
    @Delete({
        "delete from APP_COLLECTION",
        "where \" id\" = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_COLLECTION (\" id\", type, ",
        "type_id, collection_user_id, ",
        "create_time, modify_time)",
        "values (#{id,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}, ",
        "#{typeId,jdbcType=INTEGER}, #{collectionUserId,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})"
    })
    int insert(UserCollection record);

    int insertSelective(UserCollection record);

    @Select({
        "select",
        "\" id\", type, type_id, collection_user_id, create_time, modify_time",
        "from APP_COLLECTION",
        "where \" id\" = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    UserCollection selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(UserCollection record);

    @Update({
        "update APP_COLLECTION",
        "set type = #{type,jdbcType=INTEGER},",
          "type_id = #{typeId,jdbcType=INTEGER},",
          "collection_user_id = #{collectionUserId,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where \" id\" = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(UserCollection record);

    UserCollection findCollection(@Param("userId") String userId, @Param("typeId")Integer typeId,@Param("type") Integer type);


    void deleteUserCollection(@Param("userId")String userId,@Param("typeId") Integer typeId, @Param("type")Integer type);

    /**
     * 查询我的收藏
     * @param userId
     * @return
     */
    List<InstantInfoCollection> findAllMyCollection(String userId);
}